#pragma once

#include <QWidget>
#include <QListWidget>
#include "util/serverhelper.h"
#include "util/usermanager.h"
#include "util/localwordmanager.h"

namespace Ui {
class StudyPage;
}

namespace WordMemory
{
    class StudyPage : public QWidget
    {
        Q_OBJECT

    public:
        explicit StudyPage(QWidget *parent = nullptr);
        ~StudyPage();

    signals:
        void showVocabularyWordsPage(const Vocabulary &vocabulary);
        void searchWordAndSwitchPage(const QString& word);

    private slots:
        void on_searchButton_clicked();
        void on_addVocabularyButton_clicked();
        void on_vocabulariesListWidget_itemClicked(QListWidgetItem *item);

        void onSetDefaultVocabularyButtonClicked(int vocabId);
        void onDictatingDoneRefreshVocabList();

        void refreshLocalWordsDisplay();

    private:
        void setupConnections();
        void setupStyles();

        void refreshOnlineVocabularies();
        void updateVocabulariesDisplayList();

        Ui::StudyPage *ui;
        ServerHelper* serverhelper;

        QList<Vocabulary> onlineVocabulariesList;
        Vocabulary defaultVocabulary;
        Vocabulary localVocabPlaceholder;

        static const int LOCAL_VOCAB_ID;
    };
}
